﻿using AbpOne.ToolKits.Helper;
using log4net;
using Microsoft.AspNetCore.Mvc.Filters;

namespace AbpOne.HttpApi.Hosting.Filters {
    public class AbpOneExceptionFilter : IExceptionFilter {
        private readonly ILog _log;

        public AbpOneExceptionFilter() {
            _log = LogManager.GetLogger(typeof(AbpOneExceptionFilter));
        }
        
        /// <summary>
        /// 异常处理
        /// </summary>
        /// <param name="context"></param>
        public void OnException(ExceptionContext context) {
            _log.Error($"{context.HttpContext.Request.Path}|{context.Exception.Message}", context.Exception);
        }
    }
}